package com.android.huimeiqupin.adapt;

import android.graphics.Paint;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.huimeiqupin.model.group.MainSquareData;
import com.android.huimeiqupin.utils.ObjectUtils;
import com.android.huimeiqupin.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2016/8/10.
 */
public class MainlistSquareAdapt extends BaseQuickAdapter<MainSquareData.DataBean.ListBean, BaseViewHolder> {


    public MainlistSquareAdapt(int layoutResId, List<MainSquareData.DataBean.ListBean> data) {
        super(layoutResId, data);

    }

    @Override
    protected void convert(BaseViewHolder holder, MainSquareData.DataBean.ListBean listBean) {

        ((TextView) holder.getView(R.id.item_list_square_price_brfore)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        ObjectUtils.photoCircle(mContext, listBean.getPhoto(), ((ImageView) holder.getView(R.id.item_list_square_avatar)));
        ObjectUtils.photo(mContext, listBean.getThumb().get(0), ((ImageView) holder.getView(R.id.item_list_square_thumb)));
        holder.setText(R.id.item_list_square_name, listBean.getUsername());
        holder.setText(R.id.item_list_square_time, listBean.getSquare_time());
        holder.setText(R.id.item_list_square_price_after, "￥" + listBean.getTeam_price());
        holder.setText(R.id.item_list_square_price_brfore, "￥" + listBean.getPrice());
        holder.setText(R.id.item_list_square_title_type, listBean.getGoods_typename());
        holder.setText(R.id.item_list_square_content, listBean.getSquare_desc());
        int need_num = Integer.parseInt(listBean.getTeam_num()) - Integer.parseInt(listBean.getTeam_num_yes());
        holder.setText(R.id.item_list_square_num_need, need_num + "");


        switch (listBean.getGoods_typename()) {

            case "免费试用":
            case "新人专享":
                holder.setText(R.id.item_list_square_title, "                  " + listBean.getGoods_name());
                break;
            case "阶梯团":
            case "自选团":
            case "推广团":
                holder.setText(R.id.item_list_square_title, "               " + listBean.getGoods_name());
                break;
            default:
                holder.setText(R.id.item_list_square_title, "            " + listBean.getGoods_name());
                break;


        }

        holder.addOnClickListener(R.id.item_list_square_thumb);

    }


}
